/**
 * 湖南江河机电自动化设备股份有限公司 版权所有
 * Copyright @2016-2020 All Rights Reserved
 */
package com.hnjme.cnec.mdm.model;

import com.hnjme.cnec.mdm.ws.OrganizationResult;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.ibatis.type.Alias;
import org.springframework.util.Assert;

/**
 * @author outta
 * @Since 1.0 2018/8/29
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Alias("originOrganization")
@ApiModel("组织机构")
public class OriginOrganization extends Organization {

	/**
	 * 原机构代码
	 */
	@ApiModelProperty("原机构代码")
	private String originCode;

	public static OriginOrganization convert(OrganizationResult origin) {

		Assert.notNull(origin, "目标公司不能为空");
		OriginOrganization organization = new OriginOrganization();
		organization.setCode(origin.getCode());
		organization.setOriginCode(origin.getHrcode());
		organization.setName(origin.getName());
		organization.setShortName(origin.getShortname());
		organization.setEnglishName(origin.getEnName());
		organization.setEnglishShortName(origin.getEnShortname());
		organization.setSuperCode(origin.getSuperCode());
		organization.setSuperName(origin.getSuperName());
		organization.setLevel(origin.getLevel());
		organization.setAddress(origin.getAddress());
		organization.setPostcode(origin.getPostCode());
		organization.setContacts(origin.getContacts());
		organization.setContactsTel(origin.getContactsTel());
		organization.setEmail(origin.getEmail());
		organization.setCclx(origin.getCclx());
		organization.setCclxValue(origin.getCclxValue());
		organization.setStlx(origin.getStlx());
		organization.setStlxValue(origin.getStlxValue());
		organization.setStatus(true);
		return organization;
	}
}
